function init(id) {
    $.post("user/findByUserId",{id:id},function (json) {
        if (json!="index.jsp") {
            var user = json.data;
            $("#rid2").attr({value: user.rid});
            $("#uname2").attr({value: user.name});
            $("#password2").attr({value: user.password});
            if (user.gender == '男') {
                $("#sex1_2").attr({checked: 'checked'});
            } else {
                $("#sex2_2").attr({checked: 'checked'});
            }
            if (user.flag == 1) {
                $("#flag1_2").attr({checked: 'checked'})
            } else {
                $("#flag2_2").attr({checked: 'checked'})
            }
        }else {
            location.href = ''+json+''
        }
    })
}

function updateUser(id) {
    var f = false;
    $.post("user/findByUserId",{id:id},function (json) {
        if (json!="index.jsp"){
            var user = json.data
            $("#uid").attr({value:user.id});
            $("#rid").attr({value:user.rid});
            $("#uname").attr({value:user.name});
            $("#gender").attr({value:user.gender});
            $("#flag").attr({value:user.flag});
            if (user.gender == '男'){
                $("#sex1").attr({checked:'checked'});
            }else {
                $("#sex2").attr({checked:'checked'});
            }
            if (user.flag == 1){
                $("#flag1").attr({checked:'checked'})
            }else {
                $("#flag2").attr({checked:'checked'})
            }
        }else {
            location.href = ''+json+''
        }

    })

    $("#user_Modal").modal({
        backdrop:"static"
    })

    $("#password_j").blur(function () {
        let paswd = $("#password_j").val();
        $.post("user/findPassword",{id:id,password:paswd},function(data){
            if (data){
                $("#password_j").css({"border":"1px solid"})
                f = data
            }else {
                $("#password_j").css({"border":"1px solid red" })
            }
        })
    })

    $("#user_Submit").click(function () {
        if (f == false){
            alert("密码错误！")
        }else {
            $.post("user/update",$("#u_From").serialize(),function (data) {
            })
            $("#user_Modal").modal('hide')
            window.location.reload();
        }
    })

}